home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / IN.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  6KB  |  186 lines

  1. /*
  2.  * INET        An implementation of the TCP/IP protocol suite for the LINUX
  3.  *        operating system.  INET is implemented using the  BSD Socket
  4.  *        interface as the means of communication with the user level.
  5.  *
  6.  *        Definitions of the Internet Protocol.
  7.  *
  8.  * Version:    @(#)in.h    1.0.1    04/21/93
  9.  *
  10.  * Authors:    Original taken from the GNU Project <netinet/in.h> file.
  11.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12.  *
  13.  *        This program is free software; you can redistribute it and/or
  14.  *        modify it under the terms of the GNU General Public License
  15.  *        as published by the Free Software Foundation; either version
  16.  *        2 of the License, or (at your option) any later version.
  17.  */
  18. #ifndef _LINUX_IN_H
  19. #define _LINUX_IN_H
  20.  
  21. #include <linux/types.h>
  22.  
  23. /* Standard well-defined IP protocols.  */
  24. enum {
  25.   IPPROTO_IP = 0,        /* Dummy protocol for TCP        */
  26.   IPPROTO_ICMP = 1,        /* Internet Control Message Protocol    */
  27.   IPPROTO_IGMP = 2,        /* Internet Group Management Protocol    */
  28.   IPPROTO_IPIP = 4,        /* IPIP tunnels (older KA9Q tunnels use 94) */
  29.   IPPROTO_TCP = 6,        /* Transmission Control Protocol    */
  30.   IPPROTO_EGP = 8,        /* Exterior Gateway Protocol        */
  31.   IPPROTO_PUP = 12,        /* PUP protocol                */
  32.   IPPROTO_UDP = 17,        /* User Datagram Protocol        */
  33.   IPPROTO_IDP = 22,        /* XNS IDP protocol            */
  34.   IPPROTO_RSVP = 46,        /* RSVP protocol            */
  35.   IPPROTO_GRE = 47,        /* Cisco GRE tunnels (rfc 1701,1702)    */
  36.  
  37.   IPPROTO_IPV6     = 41,        /* IPv6-in-IPv4 tunnelling        */
  38.  
  39.   IPPROTO_PIM    = 103,        /* Protocol Independent Multicast    */
  40.  
  41.   IPPROTO_RAW     = 255,        /* Raw IP packets            */
  42.   IPPROTO_MAX
  43. };
  44.  
  45.  
  46. /* Internet address. */
  47. struct in_addr {
  48.     __u32    s_addr;
  49. };
  50.  
  51. #define IP_TOS        1
  52. #define IP_TTL        2
  53. #define IP_HDRINCL    3
  54. #define IP_OPTIONS    4
  55. #define IP_ROUTER_ALERT    5
  56. #define IP_RECVOPTS    6
  57. #define IP_RETOPTS    7
  58. #define IP_PKTINFO    8
  59. #define IP_PKTOPTIONS    9
  60. #define IP_MTU_DISCOVER    10
  61. #define IP_RECVERR    11
  62. #define IP_RECVTTL    12
  63. #define    IP_RECVTOS    13
  64. #define IP_MTU        14
  65.  
  66. /* BSD compatibility */
  67. #define IP_RECVRETOPTS    IP_RETOPTS
  68.  
  69. /* IP_MTU_DISCOVER values */
  70. #define IP_PMTUDISC_DONT        0    /* Never send DF frames */
  71. #define IP_PMTUDISC_WANT        1    /* Use per route hints    */
  72. #define IP_PMTUDISC_DO            2    /* Always DF        */
  73.  
  74. #define IP_MULTICAST_IF            32
  75. #define IP_MULTICAST_TTL         33
  76. #define IP_MULTICAST_LOOP         34
  77. #define IP_ADD_MEMBERSHIP        35
  78. #define IP_DROP_MEMBERSHIP        36
  79.  
  80. /* These need to appear somewhere around here */
  81. #define IP_DEFAULT_MULTICAST_TTL        1
  82. #define IP_DEFAULT_MULTICAST_LOOP       1
  83.  
  84. /* Request struct for multicast socket ops */
  85.  
  86. struct ip_mreq 
  87. {
  88.     struct in_addr imr_multiaddr;    /* IP multicast address of group */
  89.     struct in_addr imr_interface;    /* local IP address of interface */
  90. };
  91.  
  92. struct ip_mreqn
  93. {
  94.     struct in_addr    imr_multiaddr;        /* IP multicast address of group */
  95.     struct in_addr    imr_address;        /* local IP address of interface */
  96.     int        imr_ifindex;        /* Interface index */
  97. };
  98.  
  99. struct in_pktinfo
  100. {
  101.     int        ipi_ifindex;
  102.     struct in_addr    ipi_spec_dst;
  103.     struct in_addr    ipi_addr;
  104. };
  105.  
  106. /* Structure describing an Internet (IP) socket address. */
  107. #define __SOCK_SIZE__    16        /* sizeof(struct sockaddr)    */
  108. struct sockaddr_in {
  109.   sa_family_t        sin_family;    /* Address family        */
  110.   unsigned short int    sin_port;    /* Port number            */
  111.   struct in_addr    sin_addr;    /* Internet address        */
  112.  
  113.   /* Pad to size of `struct sockaddr'. */
  114.   unsigned char        __pad[__SOCK_SIZE__ - sizeof(short int) -
  115.             sizeof(unsigned short int) - sizeof(struct in_addr)];
  116. };
  117. #define sin_zero    __pad        /* for BSD UNIX comp. -FvK    */
  118.  
  119.  
  120. /*
  121.  * Definitions of the bits in an Internet address integer.
  122.  * On subnets, host and network parts are found according
  123.  * to the subnet mask, not these masks.
  124.  */
  125. #define    IN_CLASSA(a)        ((((long int) (a)) & 0x80000000) == 0)
  126. #define    IN_CLASSA_NET        0xff000000
  127. #define    IN_CLASSA_NSHIFT    24
  128. #define    IN_CLASSA_HOST        (0xffffffff & ~IN_CLASSA_NET)
  129. #define    IN_CLASSA_MAX        128
  130.  
  131. #define    IN_CLASSB(a)        ((((long int) (a)) & 0xc0000000) == 0x80000000)
  132. #define    IN_CLASSB_NET        0xffff0000
  133. #define    IN_CLASSB_NSHIFT    16
  134. #define    IN_CLASSB_HOST        (0xffffffff & ~IN_CLASSB_NET)
  135. #define    IN_CLASSB_MAX        65536
  136.  
  137. #define    IN_CLASSC(a)        ((((long int) (a)) & 0xe0000000) == 0xc0000000)
  138. #define    IN_CLASSC_NET        0xffffff00
  139. #define    IN_CLASSC_NSHIFT    8
  140. #define    IN_CLASSC_HOST        (0xffffffff & ~IN_CLASSC_NET)
  141.  
  142. #define    IN_CLASSD(a)        ((((long int) (a)) & 0xf0000000) == 0xe0000000)
  143. #define    IN_MULTICAST(a)        IN_CLASSD(a)
  144. #define IN_MULTICAST_NET    0xF0000000
  145.  
  146. #define    IN_EXPERIMENTAL(a)    ((((long int) (a)) & 0xf0000000) == 0xf0000000)
  147. #define    IN_BADCLASS(a)        IN_EXPERIMENTAL((a))
  148.  
  149. /* Address to accept any incoming messages. */
  150. #define    INADDR_ANY        ((unsigned long int) 0x00000000)
  151.  
  152. /* Address to send to all hosts. */
  153. #define    INADDR_BROADCAST    ((unsigned long int) 0xffffffff)
  154.  
  155. /* Address indicating an error return. */
  156. #define    INADDR_NONE        ((unsigned long int) 0xffffffff)
  157.  
  158. /* Network number for local host loopback. */
  159. #define    IN_LOOPBACKNET        127
  160.  
  161. /* Address to loopback in software to local host.  */
  162. #define    INADDR_LOOPBACK        0x7f000001    /* 127.0.0.1   */
  163. #define    IN_LOOPBACK(a)        ((((long int) (a)) & 0xff000000) == 0x7f000000)
  164.  
  165. /* Defines for Multicast INADDR */
  166. #define INADDR_UNSPEC_GROUP       0xe0000000U    /* 224.0.0.0   */
  167. #define INADDR_ALLHOSTS_GROUP     0xe0000001U    /* 224.0.0.1   */
  168. #define INADDR_ALLRTRS_GROUP    0xe0000002U    /* 224.0.0.2 */
  169. #define INADDR_MAX_LOCAL_GROUP  0xe00000ffU    /* 224.0.0.255 */
  170.  
  171.  
  172. /* <asm/byteorder.h> contains the htonl type stuff.. */
  173. #include <asm/byteorder.h> 
  174.  
  175. #ifdef __KERNEL__
  176. /* Some random defines to make it easier in the kernel.. */
  177. #define LOOPBACK(x)    (((x) & htonl(0xff000000)) == htonl(0x7f000000))
  178. #define MULTICAST(x)    (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
  179. #define BADCLASS(x)    (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
  180. #define ZERONET(x)    (((x) & htonl(0xff000000)) == htonl(0x00000000))
  181. #define LOCAL_MCAST(x)    (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
  182.  
  183. #endif
  184.  
  185. #endif    /* _LINUX_IN_H */
  186.